import Immutable from 'immutable';

const defaultState = new Immutable.List();

export default function menuReducer(state = defaultState, action) {
  switch(action.type) {
    case 'CREATE_MENU':
      return state;
    case 'EDIT_MENU':
      state = action.data
      return state;
    case 'DELETE_MENU':
      return state.delete(action.id);
    case 'LOAD_MENUS':
      return (action.data.success && !action.data.data.errcode )?action.data.data.menu.button:[];
    case 'ERROR_MENUS':
      return action.error.status;
    default:
      return state;
  }
}
